class Solution(object):
    def sortFeatures(self, features, responses):
        responses = [set(r.split(' ')) for r in responses]

        def cal(f):
            return sum([f in r for r in responses])

        ans = [[cal(f), index] for index, f in enumerate(features)]
        ans.sort(key=lambda x: (-x[0], x[1]))
        return [features[t[1]] for t in ans]
